<?php

function dr_xcx_url($url, $query = []) {

    $url = explode('/', trim($url, '/'));
    $uri = array();

    switch (dr_count($url)) {
        case 1:
            $uri['c'] = 'home';
            $uri['m'] = $url[0];
            break;
        case 2:
            $uri['c'] = $url[0];
            $uri['m'] = $url[1];
            break;
    }

    $query['xid'] = XCX_ID;
    $uri = @array_merge($uri, $query);

    return '/'.SELF . '?' . @http_build_query($uri);
}

/**
 * 搜索表单隐藏域
 */
function dr_xcx_search_hidden($p = []) {

    $form = '';
    $form.= '<input name="xid" type="hidden" value="'.XCX_ID.'">'.PHP_EOL;
    $form.= '<input name="m" type="hidden" value="'.$_GET['m'].'">'.PHP_EOL;
    $form.= '<input name="c" type="hidden" value="'.$_GET['c'].'">'.PHP_EOL;
    if ($p) {
        foreach ($p as $name => $value) {
            $form.= '<input name="'.$name.'" type="hidden" value="'.$value.'">'.PHP_EOL;
        }
    }

    return $form;
}

function dr_xcx_cat_value() {

}